package com.zzz.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/*
 * @author zzr
 * @date: 2025/07/07  00:14
 * @description:
 */
@WebServlet("/servlet1")
public class Servlet1 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 接收用户请求
        System.out.println("Servlet1 执行了");

         // 响应重定向 设置响应状态码为 302 同时设置 Location 响应头
        resp.sendRedirect("servlet2");
//        resp.sendRedirect("a.html");
//        resp.sendRedirect("/WEB-INF/b.html");
//        resp.sendRedirect("https://www.baidu.com");
    }
}
